﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using Pku.BookStore.IServices;
using Pku.BookStore.Model;

namespace Pku.BookStore.Services
{
    [Serializable]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Multiple)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ProductServices : IProductServices
    {
        /// <summary>
        /// 获取实例名
        /// </summary>
        private DAL.ProductDAL productDAL
        {
            get
            {
                return new DAL.ProductDAL();
            }
        }

        /// <summary>
        /// 增加图书信息
        /// </summary>
        /// <param name="entity"></param>
        public int Add(ProductModel entity)
        {
            return productDAL.Add(entity);
        }

        /// <summary>
        /// 修改图书信息
        /// </summary>
        /// <param name="entity"></param>
        public bool Modify(ProductModel entity)
        {
            return productDAL.Modify(entity);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        public List<ProductModel> Search(ProductParam param)
        {
            return productDAL.Search(param);
        }

        /// <summary>
        /// 获取总数
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetCount(Model.ProductParam param)
        {
            return productDAL.GetCount(param);
        }

        /// <summary>
        /// 获取订单实体
        /// </summary>
        /// <param name="bookID"></param>
        /// <returns></returns>
        public ProductModel GetEntityById(int bookID)
        {
            return productDAL.GetEntityById(bookID);
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="Str">关键字</param>
        /// <returns></returns>
        public bool Exist(string Str)
        {
            return productDAL.Exist(Str);
        }

        /// <summary>
        /// 修改图书封面
        /// </summary>
        /// <param name="entity"></param>
        public bool ModifyImg(ProductModel entity)
        {
            return productDAL.ModifyImg(entity);
        }

        /// <summary>
        /// 热售产品
        /// </summary>
        /// <param name="Top">Top</param>
        /// <param name="CateID">分类</param>
        /// <returns></returns>
        public List<ProductModel> GetSaleHot(int Top, int CateID)
        {
            return productDAL.GetSaleHot(Top, CateID);
        }

        /// <summary>
        /// 查询数量
        /// </summary>
        /// <returns></returns>
        public int SearchCount(ProductParam param)
        {
            return productDAL.SearchCount(param);
        }

    }
}
